import Vue from 'vue'
//导入vue-router
import VueRouter from 'vue-router'
//导入路由路径对应的view 组件,静态加载view
import Home from '../views/HomeView.vue'

//在Vue实例中使用 VueRouter
Vue.use(VueRouter)

const routes = [
  {
    path: '/',//访问路径
    name: 'Home', //路由名称（唯一，不能重复）
    component: Home //路由所指向的view组件
  },
  {
    path: '/products',
    name: 'Products',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // 动态加载view
    component: () => import(/* webpackChunkName: "about" */ '../views/ProductsView.vue')
  },
  {
    path: '/shopcart',
    name: 'ShopCart',  
    component: () => import( '../views/ShopCartView.vue')
  },
  {
    path: '/login',
    name: 'Login',  
    component: () => import( '../views/LoginView.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
